<template>
  <div class="tenant-recharge-log-container">
    <!-- 搜索区域 -->
    <ContentWrap class="search-wrapper">
      <div class="search-header">
        <div class="header-icon">
          <Icon icon="ep:search" />
        </div>
        <div class="header-content">
          <h4 class="search-title">租户充值记录管理</h4>
          <p class="search-subtitle">查询和管理租户充值记录信息</p>
        </div>
      </div>

      <div class="search-form-container">
        <el-form
          class="enhanced-search-form"
          :model="queryParams"
          ref="queryFormRef"
          :inline="true"
          label-width="68px"
        >
          <div class="form-row">
            <el-form-item label="企业租户" prop="tenantId" class="form-item">
              <el-select
                class="enhanced-select"
                v-model="queryParams.tenantId"
                filterable
                remote
                :remote-method="remoteMethod"
                clearable
                @clear="getList"
                placeholder="请选择租户名称"
                :loading="remoteLoading"
              >
                <template #prefix>
                  <Icon icon="ep:office-building" />
                </template>
                <el-option
                  v-for="item in tennatList"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id!"
                >
                  <div class="option-item">
                    <Icon icon="ep:office-building" class="option-icon" />
                    <span>{{ item.name }}</span>
                  </div>
                </el-option>
              </el-select>
            </el-form-item>

            <el-form-item label="充值金额" prop="amount" class="form-item">
              <el-input
                v-model="queryParams.amount"
                placeholder="请输入充值金额"
                clearable
                @keyup.enter="handleQuery"
                class="enhanced-input"
              >
                <template #prefix>
                  <Icon icon="ep:coin" />
                </template>
              </el-input>
            </el-form-item>

            <el-form-item label="付款方式" prop="payType" class="form-item">
              <el-select
                v-model="queryParams.payType"
                placeholder="请选择"
                clearable
                class="enhanced-select"
              >
                <template #prefix>
                  <Icon icon="ep:credit-card" />
                </template>
                <el-option label="微信收款码" value="1">
                  <div class="option-item">
                    <Icon icon="ep:chat-dot-round" class="option-icon wechat" />
                    <span>微信收款码</span>
                  </div>
                </el-option>
                <el-option label="支付宝收款码" value="2">
                  <div class="option-item">
                    <Icon icon="ep:wallet" class="option-icon alipay" />
                    <span>支付宝收款码</span>
                  </div>
                </el-option>
                <el-option label="银行卡对公" value="3">
                  <div class="option-item">
                    <Icon icon="ep:credit-card" class="option-icon bank" />
                    <span>银行卡对公</span>
                  </div>
                </el-option>
              </el-select>
            </el-form-item>

            <el-form-item label="备注说明" prop="remark" class="form-item">
              <el-input
                v-model="queryParams.remark"
                placeholder="请输入备注说明"
                clearable
                @keyup.enter="handleQuery"
                class="enhanced-input"
              >
                <template #prefix>
                  <Icon icon="ep:document" />
                </template>
              </el-input>
            </el-form-item>

            <el-form-item label="负责人" prop="ownerUserId" class="form-item">
              <el-input
                v-model="queryParams.ownerUserId"
                placeholder="请输入负责人"
                clearable
                @keyup.enter="handleQuery"
                class="enhanced-input"
              >
                <template #prefix>
                  <Icon icon="ep:user" />
                </template>
              </el-input>
            </el-form-item>

            <el-form-item label="创建时间" prop="createTime" class="form-item date-item">
              <el-date-picker
                v-model="queryParams.createTime"
                value-format="YYYY-MM-DD HH:mm:ss"
                type="daterange"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                :default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
                class="enhanced-date-picker"
              >
                <template #prefix>
                  <Icon icon="ep:calendar" />
                </template>
              </el-date-picker>
            </el-form-item>
          </div>
        </el-form>

        <div class="form-actions">
          <el-button @click="handleQuery" type="primary" class="action-btn search-btn">
            <Icon icon="ep:search" class="btn-icon" />
            搜索
          </el-button>
          <el-button @click="resetQuery" class="action-btn reset-btn">
            <Icon icon="ep:refresh" class="btn-icon" />
            重置
          </el-button>
          <el-button
            type="primary"
            plain
            @click="openForm('create')"
            v-hasPermi="['system:tenant-recharge-log:create']"
            class="action-btn add-btn"
          >
            <Icon icon="ep:plus" class="btn-icon" />
            新增
          </el-button>
          <el-button
            type="success"
            plain
            @click="handleExport"
            :loading="exportLoading"
            v-hasPermi="['system:tenant-recharge-log:export']"
            class="action-btn export-btn"
          >
            <Icon icon="ep:download" class="btn-icon" />
            导出
          </el-button>
        </div>
      </div>
    </ContentWrap>

    <!-- 列表区域 -->
    <ContentWrap class="table-wrapper">
      <div class="table-header">
        <div class="header-icon">
          <Icon icon="ep:list" />
        </div>
        <div class="header-content">
          <h4 class="table-title">充值记录列表</h4>
          <p class="table-subtitle">共 {{ total }} 条记录</p>
        </div>
      </div>

      <div class="table-container">
        <el-table
          v-loading="loading"
          :data="list"
          :stripe="true"
          :show-overflow-tooltip="true"
          class="enhanced-table"
          :header-cell-style="{ background: '#f8f9ff', color: '#303133', fontWeight: '600' }"
        >
          <el-table-column label="记录ID" align="center" prop="id" width="100px">
            <template #default="scope">
              <div class="id-cell">
                <Icon icon="ep:key" class="cell-icon" />
                <span class="cell-text">{{ scope.row.id }}</span>
              </div>
            </template>
          </el-table-column>

          <el-table-column label="企业租户" align="left" prop="tenantName" width="180px">
            <template #default="scope">
              <div class="tenant-cell">
                <Icon icon="ep:office-building" class="cell-icon" />
                <span class="cell-text">{{ scope.row.tenantName }}</span>
              </div>
            </template>
          </el-table-column>

          <el-table-column label="充值金额" align="left" prop="amount" width="150px">
            <template #default="scope">
              <div class="amount-cell">
                <Icon icon="ep:coin" class="cell-icon" />
                <span class="amount-text">{{ scope.row.amount }}</span>
                <span class="unit">元</span>
              </div>
            </template>
          </el-table-column>

          <el-table-column label="付款方式" align="center" prop="payType" width="150px">
            <template #default="scope">
              <div class="pay-type-cell">
                <el-tag
                  :type="payTypeEnum[scope.row.payType].type"
                  effect="dark"
                  class="enhanced-tag"
                >
                  <Icon
                    :icon="
                      scope.row.payType == 1
                        ? 'ep:chat-dot-round'
                        : scope.row.payType == 2
                          ? 'ep:wallet'
                          : 'ep:credit-card'
                    "
                    class="tag-icon"
                  />
                  {{ payTypeEnum[scope.row.payType].value }}
                </el-tag>
              </div>
            </template>
          </el-table-column>

          <el-table-column label="备注说明" align="center" prop="remark" width="150px">
            <template #default="scope">
              <div class="remark-cell">
                <Icon icon="ep:document" class="cell-icon" />
                <span class="cell-text">{{ scope.row.remark || '-' }}</span>
              </div>
            </template>
          </el-table-column>

          <el-table-column label="负责人" align="center" prop="ownerUserName" width="150px">
            <template #default="scope">
              <div class="owner-cell">
                <Icon icon="ep:user" class="cell-icon" />
                <span class="cell-text">{{ scope.row.ownerUserName || '-' }}</span>
              </div>
            </template>
          </el-table-column>

          <el-table-column label="图片附件" align="left" prop="attachment">
            <template #default="scope">
              <div class="attachment-cell">
                <div
                  v-if="scope.row.attachment && scope.row.attachment.length > 0"
                  class="attachment-list"
                >
                  <div
                    v-for="(item, index) in scope.row.attachment"
                    :key="index"
                    class="attachment-item"
                    @click="onShowPreview(item)"
                  >
                    <el-image :src="item" fit="cover" class="attachment-image">
                      <template #error>
                        <div class="image-error">
                          <Icon icon="ep:picture" />
                        </div>
                      </template>
                    </el-image>
                    <div class="image-overlay">
                      <Icon icon="ep:zoom-in" />
                    </div>
                  </div>
                </div>
                <div v-else class="no-attachment">
                  <Icon icon="ep:folder-opened" class="no-attachment-icon" />
                  <span>暂无附件</span>
                </div>
              </div>
            </template>
          </el-table-column>

          <el-table-column
            label="创建时间"
            align="center"
            prop="createTime"
            :formatter="dateFormatter"
          >
            <template #default="scope">
              <div class="time-cell">
                <Icon icon="ep:clock" class="cell-icon" />
                <span class="cell-text">{{
                  dateFormatter(scope.row, null, scope.row.createTime)
                }}</span>
              </div>
            </template>
          </el-table-column>

          <el-table-column label="操作" align="center" width="150px">
            <template #default="scope">
              <div class="action-cell">
                <el-button
                  link
                  type="danger"
                  @click="handleDelete(scope.row.id)"
                  v-hasPermi="['system:tenant-recharge-log:delete']"
                  class="action-button delete-btn"
                >
                  <Icon icon="ep:delete" class="btn-icon" />
                  删除
                </el-button>
              </div>
            </template>
          </el-table-column>
        </el-table>

        <!-- 分页 -->
        <div class="pagination-wrapper">
          <Pagination
            :total="total"
            v-model:page="queryParams.pageNo"
            v-model:limit="queryParams.pageSize"
            @pagination="getList"
          />
        </div>
      </div>
    </ContentWrap>

    <!-- 图片预览弹窗 -->
    <Dialog v-model="showPreview" title="图片预览" width="500" class="preview-dialog">
      <div class="preview-container">
        <el-image :src="showPreviewImgs" class="preview-image" fit="contain">
          <template #error>
            <div class="preview-error">
              <Icon icon="ep:picture" />
              <span>图片加载失败</span>
            </div>
          </template>
        </el-image>
      </div>
    </Dialog>

    <!-- 表单弹窗：添加/修改 -->
    <TenantRechargeLogForm ref="formRef" @success="getList" />
  </div>
</template>

<script setup lang="ts">
import download from '@/utils/download'
import * as TenantRechargeLogApi from '@/api/system/tenantrechargelog'
import TenantRechargeLogForm from './TenantRechargeLogForm.vue'
import { dateFormatter } from '@/utils/formatTime.ts'
// import * as UserApi from '@/api/system/user'
import * as TenantApi from '@/api/system/tenant'

defineOptions({ name: 'TenantRechargeLog' })

const message = useMessage() // 消息弹窗
const { t } = useI18n() // 国际化
const showPreview = ref(false)
const showPreviewImgs = ref(null)
const onShowPreview = (data) => {
  showPreview.value = true
  showPreviewImgs.value = data
}
const loading = ref(true) // 列表的加载中
const total = ref(0) // 列表的总页数
const list = ref([]) // 列表的数据
const queryParams = reactive({
  pageNo: 1,
  pageSize: 10,
  amount: null,
  payType: null,
  remark: null,
  ownerUserId: null,
  attachment: null,
  createTime: [],
  tenantId: null
})
const queryFormRef = ref() // 搜索的表单
const exportLoading = ref(false) // 导出的加载中

/** 查询列表 */
const getList = async () => {
  loading.value = true
  try {
    const data = await TenantRechargeLogApi.getTenantRechargeLogPageByAdmin(queryParams)
    list.value = data.list
    total.value = data.total
  } finally {
    loading.value = false
  }
}

const tennatList = ref([])
const remoteLoading = ref(false)
const remoteMethod = async (query: string) => {
  remoteLoading.value = true
  const data = await TenantApi.getTenantPage({
    pageNo: 1,
    pageSize: 10,
    name: query
  })
  tennatList.value = data.list
  remoteLoading.value = false
  getList()
}

const payTypeEnum = {
  1: {
    type: 'success',
    value: '微信收款码'
  },
  2: {
    type: 'primary',
    value: '支付宝收款码'
  },
  3: {
    type: 'danger',
    value: '银行卡对公'
  }
}

/** 搜索按钮操作 */
const handleQuery = () => {
  queryParams.pageNo = 1
  getList()
}

/** 重置按钮操作 */
const resetQuery = () => {
  queryFormRef.value.resetFields()
  handleQuery()
}

/** 添加/修改操作 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
  formRef.value.open(type, id)
}

/** 删除按钮操作 */
const handleDelete = async (id: number) => {
  try {
    // 删除的二次确认
    await message.delConfirm()
    // 发起删除
    await TenantRechargeLogApi.deleteTenantRechargeLog(id)
    message.success(t('common.delSuccess'))
    // 刷新列表
    await getList()
  } catch {}
}

/** 导出按钮操作 */
const handleExport = async () => {
  try {
    // 导出的二次确认
    await message.exportConfirm()
    // 发起导出
    exportLoading.value = true
    const data = await TenantRechargeLogApi.exportTenantRechargeLog(queryParams)
    download.excel(data, '租户充值记录.xls')
  } catch {
  } finally {
    exportLoading.value = false
  }
}

/** 初始化 **/
onMounted(() => {
  getList()
})
</script>

<style lang="scss" scoped>
// 主题色变量
$primary-color: #0052cc;
$primary-light: rgba(0, 82, 204, 0.1);
$primary-border: rgba(0, 82, 204, 0.3);
$success-color: #67c23a;
$warning-color: #e6a23c;
$danger-color: #f56c6c;
$info-color: #909399;
$text-primary: #303133;
$text-regular: #606266;
$text-secondary: #909399;
$text-placeholder: #c0c4cc;
$border-color: #dcdfe6;
$border-light: #e4e7ed;
$bg-color: #f5f7fa;
$shadow-light: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
$shadow-base:
  0 2px 4px rgba(0, 0, 0, 0.12),
  0 0 6px rgba(0, 0, 0, 0.04);
$border-radius: 12px;
$border-radius-small: 8px;

.tenant-recharge-log-container {
  padding: 0;
  background: $bg-color;
  min-height: 100vh;

  @media (max-width: 768px) {
    padding: 0;
  }
}

/* 搜索区域样式 */
.search-wrapper {
  margin-bottom: 16px;
  border-radius: $border-radius;
  overflow: hidden;
  box-shadow: $shadow-light;
  border: 1px solid $border-light;

  :deep(.el-card__body) {
    padding: 0;
  }
}

.search-header {
  display: flex;
  align-items: center;
  padding: 20px 24px;
  background: linear-gradient(135deg, $primary-color 0%, #1d4ed8 100%);
  color: white;

  @media (max-width: 768px) {
    padding: 16px 20px;
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }
}

.header-icon {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: $border-radius-small;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;

  @media (max-width: 768px) {
    width: 36px;
    height: 36px;
    font-size: 16px;
  }
}

.header-content {
  flex: 1;
  margin-left: 12px;

  @media (max-width: 768px) {
    margin-left: 0;
  }
}

.search-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 4px 0;

  @media (max-width: 768px) {
    font-size: 16px;
  }
}

.search-subtitle {
  font-size: 13px;
  opacity: 0.9;
  margin: 0;

  @media (max-width: 768px) {
    font-size: 12px;
  }
}

.search-form-container {
  padding: 24px;
  background: white;

  @media (max-width: 768px) {
    padding: 16px;
  }
}

.enhanced-search-form {
  .form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;

    @media (max-width: 768px) {
      flex-direction: column;
      gap: 12px;
      margin-bottom: 16px;
    }
  }

  .form-item {
    flex: 1;
    min-width: 240px;
    margin-bottom: 0;

    @media (max-width: 768px) {
      min-width: auto;
      flex: none;
    }

    &.date-item {
      min-width: 300px;

      @media (max-width: 768px) {
        min-width: auto;
      }
    }

    :deep(.el-form-item__label) {
      font-weight: 600;
      color: $text-regular;
      padding-bottom: 8px;

      @media (max-width: 768px) {
        font-size: 14px;
        width: 100% !important;
        text-align: left !important;
        margin-bottom: 8px;
      }
    }

    :deep(.el-form-item__content) {
      @media (max-width: 768px) {
        margin-left: 0 !important;
      }
    }
  }

  // H5适配：表单项垂直布局
  @media (max-width: 768px) {
    :deep(.el-form-item) {
      display: block;
    }
  }
}

/* 输入框样式 */
.enhanced-input {
  width: 100%;

  :deep(.el-input__wrapper) {
    border-radius: $border-radius-small;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: all 0.2s ease;
    padding: 12px 16px;

    &:hover {
      box-shadow: 0 4px 12px rgba(0, 82, 204, 0.1);
    }

    &.is-focus {
      box-shadow: 0 4px 12px rgba(0, 82, 204, 0.2);
      border-color: $primary-color;
    }
  }
}

/* 选择器样式 */
.enhanced-select {
  width: 100%;

  :deep(.el-select__wrapper) {
    border-radius: $border-radius-small;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: all 0.2s ease;
    padding: 8px 16px;

    &:hover {
      box-shadow: 0 4px 12px rgba(0, 82, 204, 0.1);
    }

    &.is-focused {
      box-shadow: 0 4px 12px rgba(0, 82, 204, 0.2);
      border-color: $primary-color;
    }
  }
}

/* 日期选择器样式 */
.enhanced-date-picker {
  width: 100%;

  :deep(.el-input__wrapper) {
    border-radius: $border-radius-small;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    transition: all 0.2s ease;
    padding: 12px 16px;

    &:hover {
      box-shadow: 0 4px 12px rgba(0, 82, 204, 0.1);
    }

    &.is-focus {
      box-shadow: 0 4px 12px rgba(0, 82, 204, 0.2);
      border-color: $primary-color;
    }
  }
}

/* 选项样式 */
.option-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}

.option-icon {
  font-size: 14px;

  &.wechat {
    color: #07c160;
  }

  &.alipay {
    color: #1677ff;
  }

  &.bank {
    color: $danger-color;
  }
}

/* 操作按钮区域 */
.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;

  @media (max-width: 768px) {
    flex-direction: column;
    gap: 8px;
  }
}

.action-btn {
  border-radius: $border-radius-small;
  padding: 10px 16px;
  font-weight: 500;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 6px;

  &:hover {
    transform: translateY(-1px);
  }

  @media (max-width: 768px) {
    width: 100%;
    justify-content: center;
    padding: 12px 16px;
  }

  .btn-icon {
    font-size: 14px;
  }

  &.search-btn {
    background: linear-gradient(135deg, $primary-color 0%, #1d4ed8 100%);
    border: none;

    &:hover {
      box-shadow: 0 4px 12px rgba(0, 82, 204, 0.3);
    }
  }

  &.reset-btn {
    border: 2px solid $border-color;
    color: $text-regular;

    &:hover {
      border-color: $primary-color;
      color: $primary-color;
      background: $primary-light;
    }
  }

  &.add-btn {
    border: 2px solid $primary-color;
    color: $primary-color;

    &:hover {
      background: $primary-color;
      color: white;
    }
  }

  &.export-btn {
    border: 2px solid $success-color;
    color: $success-color;

    &:hover {
      background: $success-color;
      color: white;
    }
  }
}

/* 表格区域样式 */
.table-wrapper {
  border-radius: $border-radius;
  overflow: hidden;
  box-shadow: $shadow-light;
  border: 1px solid $border-light;

  :deep(.el-card__body) {
    padding: 0;
  }
}

.table-header {
  display: flex;
  align-items: center;
  padding: 20px 24px;
  background: linear-gradient(135deg, $primary-color 0%, #1d4ed8 100%);
  color: white;

  @media (max-width: 768px) {
    padding: 16px 20px;
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }
}

.table-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 4px 0;

  @media (max-width: 768px) {
    font-size: 16px;
  }
}

.table-subtitle {
  font-size: 13px;
  opacity: 0.9;
  margin: 0;

  @media (max-width: 768px) {
    font-size: 12px;
  }
}

.table-container {
  background: white;
  overflow-x: auto;
}

.enhanced-table {
  :deep(.el-table__header) {
    th {
      background: linear-gradient(135deg, #f8f9ff 0%, #f0f2ff 100%) !important;
      color: $text-primary !important;
      font-weight: 600 !important;
      border-bottom: 2px solid $primary-light;
      padding: 16px 12px;
    }
  }

  :deep(.el-table__body) {
    tr {
      transition: all 0.3s ease;

      &:hover {
        background: $primary-light !important;
      }

      td {
        padding: 14px 12px;
        border-bottom: 1px solid $border-light;
      }
    }

    .el-table__row--striped {
      background: #fafbff;

      &:hover {
        background: $primary-light !important;
      }
    }
  }

  // H5适配
  @media (max-width: 768px) {
    :deep(.el-table__header) th {
      padding: 12px 8px;
      font-size: 13px;
    }

    :deep(.el-table__body) td {
      padding: 12px 8px;
      font-size: 12px;
    }
  }
}

/* 表格单元格样式 */
.id-cell,
.tenant-cell,
.remark-cell,
.owner-cell,
.time-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.amount-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
}

.pay-type-cell {
  display: flex;
  justify-content: center;
}

.cell-icon {
  font-size: 14px;
  flex-shrink: 0;
  color: $primary-color;
}

.cell-text {
  color: $text-regular;
  font-weight: 500;

  @media (max-width: 768px) {
    font-size: 12px;
  }
}

.amount-text {
  color: $primary-color;
  font-weight: 600;
  font-size: 16px;

  @media (max-width: 768px) {
    font-size: 14px;
  }
}

.unit {
  font-size: 11px;
  color: $text-secondary;
  background: rgba(0, 0, 0, 0.05);
  padding: 1px 4px;
  border-radius: 3px;

  @media (max-width: 768px) {
    font-size: 10px;
  }
}

/* 标签样式 */
.enhanced-tag {
  border-radius: 6px;
  font-weight: 500;
  padding: 4px 8px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;

  @media (max-width: 768px) {
    font-size: 11px;
    padding: 3px 6px;
  }
}

.tag-icon {
  font-size: 12px;
}

/* 附件样式 */
.attachment-cell {
  padding: 8px;
}

.attachment-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.attachment-item {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: $border-radius-small;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s ease;

  &:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);

    .image-overlay {
      opacity: 1;
    }
  }

  @media (max-width: 768px) {
    width: 60px;
    height: 60px;
  }
}

.attachment-image {
  width: 100%;
  height: 100%;
  border-radius: $border-radius-small;
}

.image-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.image-error {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: $bg-color;
  color: $text-secondary;
  font-size: 24px;
}

.no-attachment {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: $text-secondary;
  font-size: 12px;

  @media (max-width: 768px) {
    padding: 16px;
    font-size: 11px;
  }
}

.no-attachment-icon {
  font-size: 24px;
  margin-bottom: 4px;
  opacity: 0.5;

  @media (max-width: 768px) {
    font-size: 20px;
  }
}

/* 操作按钮 */
.action-cell {
  display: flex;
  justify-content: center;
}

.action-button {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.3s ease;

  &:hover {
    transform: scale(1.05);
  }

  .btn-icon {
    font-size: 12px;
  }

  @media (max-width: 768px) {
    padding: 4px 8px;
    font-size: 11px;
  }

  &.delete-btn:hover {
    background: rgba(245, 108, 108, 0.1);
    color: $danger-color;
  }
}

/* 分页样式 */
.pagination-wrapper {
  display: flex;
  justify-content: center;
  padding: 20px 24px;
  background: white;
  border-top: 1px solid $border-light;

  @media (max-width: 768px) {
    padding: 16px 20px;
  }

  :deep(.el-pagination) {
    .el-pager li {
      border-radius: 6px;
      margin: 0 2px;
      transition: all 0.3s ease;

      &:hover {
        background: $primary-light;
        color: $primary-color;
      }

      &.is-active {
        background: $primary-color;
        color: white;
      }
    }

    .btn-prev,
    .btn-next {
      border-radius: 6px;
      transition: all 0.3s ease;

      &:hover {
        background: $primary-light;
        color: $primary-color;
      }
    }

    @media (max-width: 768px) {
      .el-pagination__sizes,
      .el-pagination__jump {
        display: none;
      }
    }
  }
}

/* 图片预览弹窗 */
.preview-dialog {
  :deep(.el-dialog) {
    border-radius: $border-radius;
    overflow: hidden;

    @media (max-width: 768px) {
      width: 95% !important;
      margin: 0 auto;
    }
  }
}

.preview-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 400px;
  background: #f5f5f5;
  border-radius: $border-radius-small;

  @media (max-width: 768px) {
    min-height: 300px;
  }
}

.preview-image {
  max-width: 100%;
  max-height: 500px;
  border-radius: $border-radius-small;

  @media (max-width: 768px) {
    max-height: 300px;
  }
}

.preview-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: $text-secondary;
  font-size: 16px;
  gap: 8px;

  @media (max-width: 768px) {
    font-size: 14px;
  }
}

/* 深色模式适配 */
@media (prefers-color-scheme: dark) {
  .tenant-recharge-log-container {
    background: #1f2937;
  }

  .search-wrapper,
  .table-wrapper {
    background: #374151;
    border-color: #4b5563;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  }

  .search-form-container,
  .table-container,
  .pagination-wrapper {
    background: #374151;
  }

  .search-title,
  .table-title {
    color: #f9fafb;
  }

  .cell-text {
    color: #f9fafb;
  }

  .enhanced-table {
    :deep(.el-table__header) {
      th {
        background: #4b5563 !important;
        color: #f9fafb !important;
        border-bottom-color: #6b7280;
      }
    }

    :deep(.el-table__cell) {
      border-bottom-color: #4b5563;
    }
  }

  .enhanced-input,
  .enhanced-select,
  .enhanced-date-picker {
    :deep(.el-input__wrapper),
    :deep(.el-select__wrapper) {
      background: #4b5563;
      border-color: #6b7280;

      .el-input__inner {
        color: #f9fafb;
      }
    }
  }

  .option-icon {
    &.wechat {
      color: #34d399;
    }

    &.alipay {
      color: #60a5fa;
    }

    &.bank {
      color: #f87171;
    }
  }

  .unit {
    background: rgba(255, 255, 255, 0.1);
    color: #9ca3af;
  }

  .image-error {
    background: #4b5563;
    color: #9ca3af;
  }

  .no-attachment {
    color: #9ca3af;
  }

  .preview-container {
    background: #4b5563;
  }
}

/* 响应式优化 */
@media (max-width: 480px) {
  .search-header,
  .table-header {
    padding: 12px 16px;
  }

  .search-form-container {
    padding: 12px;
  }

  .pagination-wrapper {
    padding: 12px 16px;
  }

  .enhanced-table {
    :deep(.el-table__header) th {
      padding: 10px 6px;
      font-size: 12px;
    }

    :deep(.el-table__body) td {
      padding: 10px 6px;
      font-size: 11px;
    }
  }

  .cell-text {
    font-size: 11px;
  }

  .amount-text {
    font-size: 13px;
  }

  .unit {
    font-size: 9px;
  }

  .action-button {
    padding: 3px 6px;
    font-size: 10px;
  }

  .enhanced-tag {
    font-size: 10px;
    padding: 2px 4px;
  }

  .attachment-item {
    width: 50px;
    height: 50px;
  }
}
</style>
